var events = require("events");
var EventEmitter = events.EventEmitter;

var eventEmitter = new EventEmitter();

var listener1 = function(){
	console.log("监听器 listener1 执行");
}

var listener2 = function() {
	console.log("监听器 listener2 执行");
}

eventEmitter.addListener("event1", listener1);
eventEmitter.on("event1", listener2);

var listenerCount = EventEmitter.listenerCount(eventEmitter, "event1");
console.log("监听器的个数为: " + listenerCount);
eventEmitter.emit("event1");

eventEmitter.removeListener("event1", listener1);
listenerCount = EventEmitter.listenerCount(eventEmitter, "event1");
console.log("监听器的个数为: " + listenerCount);
eventEmitter.emit("event1");

eventEmitter.removeListener("event1", listener2);
listenerCount = EventEmitter.listenerCount(eventEmitter, "event1");
console.log("监听器的个数为: " + listenerCount);
eventEmitter.emit("event1");

























